<template>
  <div class="page-header">
    <div class="container">
      <!-- 左侧标题区 -->
      <div class="header-left">
        <h1 class="title-main">{{ title }}</h1>
        <p v-if="subtitle" class="title-sub">{{ subtitle }}</p>
      </div>

      <!-- 右侧操作区 -->
      <div class="header-right">
        <!-- 订单入口 -->
        <a @click="comeToGoodsPage" class="orders-entry">
          <i class="icon-order">📦</i>
          <span class="orders-text">我的订单</span>
        </a>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      required: true,
      default: '页面标题'
    },
    subtitle: {
      type: String,
      default: ''
    }
  },
  methods: {
    comeToGoodsPage() {
      this.$router.push('/order')
    }
  }
}
</script>

<style scoped>
/* 基础样式重置 */
.page-header {
  background: #ffffff;
  border-bottom: 2px solid #f0f2f5;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  position: relative;
  z-index: 1000;
  height: 72px;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
}

/* 左侧标题区 */
.header-left {
  width: 300px;
  flex-shrink: 0;
  margin-right: 40px;
  overflow: hidden;
}

.title-main {
  font-size: 24px;
  font-weight: 600;
  color: #2c3e50;
  margin: 0 0 8px 0;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.title-sub {
  font-size: 15px;
  color: #7f8c8d;
  margin: 0;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 右侧操作区 */
.header-right {
  flex-grow: 1;
  display: flex;
  align-items: center;
  gap: 32px;
  justify-content: flex-end;
}

/* 订单入口 */
.orders-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #34495e;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.orders-entry:hover {
  background-color: #f8f9fa;
  text-decoration: none;
}

.icon-order {
  font-size: 18px;
}

.orders-text {
  font-size: 15px;
  font-weight: 500;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .page-header {
    height: auto;
    padding: 16px 0;
  }

  .container {
    padding: 0 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 24px;
  }

  .header-left {
    width: 100%;
    margin-right: 0;
    margin-bottom: 24px;
    text-align: left;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
    flex-grow: 0;
  }

  .title-main {
    font-size: 22px;
    white-space: normal;
  }

  .orders-entry {
    padding: 6px 12px;
  }
}
</style>